// Created by liusc on 2020/8/5-9:24.
<template>
  <div class="budgetWrap box">
    <div class="resource-manage">
      <div class="card-box">
        <div class="card-title">
          <span>申请信息</span>
        </div>
        <el-form ref="add-form" :model="form" :rules="rules" label-width="auto" class="form-wrap">
          <el-row>
            <el-col :span="8">
              <el-form-item label="预算编号" prop="budgetCode">
                <el-col class="in_txt">{{form.applyData.budgetCode}}</el-col>
              </el-form-item>
            </el-col>
            <el-col :span="16">
              <el-form-item label="申请名称" prop="applyName">
                <el-col class="in_txt">{{form.applyData.applyName}}</el-col>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="申请部门">
                <el-col class="in_txt">{{applyDept2}}</el-col>
              </el-form-item>
            </el-col>
            <el-col :span="16">
              <el-form-item label="申请类型">
                <el-col class="in_txt">{{applyType2}}</el-col>
              </el-form-item>
            </el-col>
          </el-row>

          <div class="card-title">
            <span>预算调整</span>
          </div>

          <el-table
            :data="form.itemValueList"
            class="dubgetTable mt20"
            row-key="itemId"
            default-expand-all
            :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
          >
            <el-table-column class="weight" header-align="center" prop="itemName" label="科目" width="300">
              <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.itemName }}</span>
                <el-switch
                  v-model="scope.row.isNead"
                  v-if="scope.row.children == null"
                  :width="28"
                  active-value="1"
                  inactive-value="0"
                  @change="handleIsNeadChange($event, scope.row)"
                />
              </template>
            </el-table-column>
            <el-table-column align="center" label="原金额(元)">
              <el-table-column align="center" prop="itemValue" :label="`${form.applyData.budgetSum}`" />
            </el-table-column>
            <el-table-column align="center" label="调整后金额(元)">
              <el-table-column align="center" prop="itemValuePre" :label="`${form.applyData.budgetSum2 || '暂无数据'}`">
                <template slot-scope="scope">
                  <el-input
                    clearable
                    maxlength="15"
                    @input="budgetChange()"
                    v-only-number="{min:0,precision:2}"
                    v-model="scope.row.itemValuePre"
                    :disabled="scope.row.isNead == 0 || scope.row.children !== null"
                  />
                </template>
              </el-table-column>
            </el-table-column>
            <el-table-column align="center" label="变化金额(元)">
              <el-table-column align="center" prop="itemValue" :label="`${form.applyData.changeAmount || '暂无数据'}`">
                <template slot-scope="scope">{{`${scope.row.changeAmount>0 ? '+':''}${scope.row.changeAmount || 0}`}}</template>
              </el-table-column>
            </el-table-column>
          </el-table>

          <el-form-item class="mt20" label="备注" prop="applyData.remarks">
            <el-input v-model="form.applyData.remarks" placeholder="请输入备注" />
          </el-form-item>
        </el-form>
      </div>
    </div>

    <fileUpload ref="fileUpload" type="edit" :busId="parameterId" :fileId="fileId" @onSuccess="handleCompleted" />
    <fileUpload type="preview" :busId="applyFileId" :fileId="applyFileId2" firstTitle="预算申请附件材料" secondTitle="预算申请业务依据" />
    <fileUpload type="preview" :busId="amendFileId" :fileId="amendFileId2" firstTitle="预算调整附件材料" secondTitle="预算调整业务依据" />

    <div class="card-box pl20 pr20">
      <div class="card-title">
        <span>编辑历史记录</span>
      </div>

      <el-table :data="editList" class="dubgetTable mt20">
        <el-table-column label="修改内容" prop="itemName" align="center">
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" :content="scope.row.editContent" placement="top">
              <el-input v-model="scope.row.editContent" readonly="readonly"></el-input>
            </el-tooltip>
          </template>
        </el-table-column>

        <el-table-column label="时间" prop="itemValue" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.createTime" readonly="readonly"></el-input>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <div slot="footer" class="footer" style="padding-right: 0px">
      <el-button @click="cancel">取 消</el-button>
      <el-button type="primary" v-throttle="[commit2]">汇总并提交</el-button>
    </div>
  </div>
</template>

<script src="./parameter_edit.js"></script>
<style scoped lang="scss">
@import "./parameter_edit";
</style>

